﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#include "string.h"
//#include <string>
void test1()
{
	string str;
	str.push_back('1');
	str.push_back('1');
	str.push_back('1');
	str.push_back('1');
	str.push_back('1');
	str.push_back('1');

	cout << str.c_str() << endl;
}

void test2()
{
	my_std::string str;
	my_std::string str2 = "Writing ";
	my_std::string str3 = "print 10 and then 5 more";

	// used in the same order as described above:
	str.append(str2);                       // "Writing "
	cout << str.c_str() << endl;
	str.append(str3, 6, 3);                   // "10 "
	cout << str.c_str() << endl;
	str.append("dots are cool",0, 5);          // "dots "
	cout << str.c_str() << endl;
	str.append("here: ",0);                   // "here: "
	cout << str.c_str() << endl;
	//str.append(10u, '.');                    // ".........."
	//str.append(str3.begin() + 8, str3.end());  // " and then 5 more"
	////str.append<int>(5, 0x2E);                // "....."

	str += "123456";

	str += '1';

	cout << str.c_str() << endl;
}


void test3()
{
	my_std::string str;
	my_std::string str2 = "Writing ";
	my_std::string str3 = "print 10 and then 5 more";

	str3.insert(str2, 0, 1);
	cout << str3.c_str() << endl;
}
void test4()
{
	my_std::string str;
	my_std::string str2 = "Writing ";
	my_std::string str3 = "print 10 and then 5 more";


	auto p = str2.find("ng");
	cout << (str2[p]) << endl;
}

void test5()
{
	// 21：18继续
	my_std::string url = "ftp://www.baidu.com/?tn=65081411_1_oem_dg";

	size_t pos1 = url.find("://");
	if (pos1 != my_std::string::npos)
	{
		my_std::string protocol = url.substr(0, pos1);
		cout << protocol << endl;
	}

	size_t pos2 = url.find('/', pos1 + 3);
	if (pos2 != my_std::string::npos)
	{
		my_std::string domain = url.substr(pos1 + 3, pos2);
		my_std::string uri = url.substr(pos2 + 1,url.size());

		cout << domain << endl;
		cout << uri << endl;
	}
}
void test6()
{
	my_std::string p;
	cin >> p;
	cout << p << endl;
}


void test8()
{
	//string s1("bb");
	//string s2("aaa");
	//cout << (s1 < s2) << endl;

	my_std::string s1("hello");
	my_std::string s2("hello");
	cout << (s1 < s2) << endl;
	cout << (s1 > s2) << endl;
	cout << (s1 == s2) << endl << endl;


	my_std::string s3("hello");
	my_std::string s4("helloxxx");
	cout << (s3 < s4) << endl;
	cout << (s3 > s4) << endl;
	cout << (s3 == s4) << endl << endl;


	my_std::string s5("helloxxx");
	my_std::string s6("hello");
	cout << (s5 < s6) << endl;
	cout << (s5 > s6) << endl;
	cout << (s5 == s6) << endl << endl;
}

//int main()
//{
//	//test8();
//	string p;
//	char ch = cin.get();
//	while(ch != '\n')
//	{
//		p += ch;
//		ch = cin.get();
//	}
//
//	cout << p << endl;
//	reverse(p.begin(), p.end());
//	cout << p << endl;
//	auto q = p.find(' ');
//	if (q == p.npos)
//	{
//		q = p.size();
//	}
//
//	cout << q;
//	return 0;
//}

class Solution {
public:
	static my_std::string reverseWords(my_std::string s)
	{
		auto be = s.begin();

		while (be != s.end())
		{
			auto it = s.find(be, s.end(), ' ');
			reverse(be, it);
			if (it == s.end())
			{
				break;
			}
			be = it + 1;
		}
		return s;
	}
};


int main()
{
	Solution::reverseWords("1324 243546");



	return 0;
}